package com.itmeima.text5;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Demo1 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {


        ClassLoader loader = ClassLoader.getSystemClassLoader();

        InputStream is = loader.getResourceAsStream("a.properties");

        Properties prop = new Properties();

        prop.load(is);

        String className = prop.getProperty("className");
        String methodName = prop.getProperty("methodName");

        is.close();
        Class clazz = Class.forName(className);

        Teacher teacher = (Teacher) clazz.getDeclaredConstructor().newInstance();

        Method method = clazz.getDeclaredMethod(methodName);

        method.invoke(teacher);

    }
}
